<template>
  <view :style="themeColor">
    <view class="page">
      <!---flex布局flex布局开始-->
      <view class="flex flex-wrap align-center justify-end benben-flex-layout">
        <view class='flex flex-wrap align-center justify-center loginPage_fd0_0' @tap.stop="switchLanguageFunc(state)">
          <text class='loginPage_fd0_0_c0' v-if=" state=='1'">{{$t('繁体中文')}}</text><text class='loginPage_fd0_0_c0'
            v-if=" state=='2'">{{$t('简体中文')}}</text>
          <image class='loginPage_fd0_0_c1' mode="aspectFit" :src='STATIC_URL+"70.png"'></image>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center loginPage_flex_1">
        <image class='loginPage_fd1_0' mode="aspectFit" :src='STATIC_URL+"3.png"'></image>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center loginPage_flex_2">
        <view>
          <benben-flex-tabs class-name='loginPage_benbenTabsfd2_0' v-model="tabls" ref="benben_tabsfd2_0"
            select-mark="benben_tabsfd2_0" key="benben_tabsfd2_0" :open-title-type='false' :open-sticky='false' :top='0'
            :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd2_0">

            <scroll-view @scroll="tabsInfofd2_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd2_0"
              class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left.sync="tabsInfofd2_0.moveX"
              scroll-with-animation="all .3s ease">
              <view class="benben-tabs-content" id="benben_tabsfd2_0-content">
                <view id="benben_tabsfd2_0-title" class="benben-tabs-title flex align-center flex ">
                  <view
                    :class="{ 'checkTitlefd2_0': tabls == '1', 'flex flex-wrap align-center loginPage_titlefd2_0_c3': true }"
                    @tap="tabls = '1'" :id="`benben_tabsfd2_0-title-item-${'1'}`">

                    <text>{{$t('手机号登录')}}</text>

                  </view>
                  <view
                    :class="{ 'checkTitlefd2_0': tabls == '2', 'flex flex-wrap align-center loginPage_titlefd2_0_c4': true }"
                    @tap="tabls = '2'" :id="`benben_tabsfd2_0-title-item-${'2'}`">

                    <text>{{$t('邮箱号登录')}}</text>

                  </view>
                </view>
                <view :style="{ left: tabsInfofd2_0.lineleft, maxWidth: tabsInfofd2_0.lineWidth ,}"
                  id="benben_tabsfd2_0-line" class="benben-tabs-line flex benben-flex-tabs-line loginPage_linefd2_0">
                </view>
              </view>
            </scroll-view>

          </benben-flex-tabs>

        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout loginPage_flex_3">
        <view class='flex flex-direction flex-wrap align-stretch' v-if=" tabls=='1'">
          <view class='flex flex-wrap align-center loginPage_fd3_0_c0'>
            <image class='loginPage_fd3_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"75.png"'></image>
            <view class='flex flex-wrap align-center loginPage_fd3_0_c0_c1'>
              <text class='loginPage_fd3_0_c0_c1_c0' v-if=" state=='1'">{{$t('+852')}}</text><text
                class='loginPage_fd3_0_c0_c1_c0' v-if=" state=='2'">{{$t('+86')}}</text>
              <image class='loginPage_fd3_0_c0_c1_c1' mode="aspectFit" :src='STATIC_URL+"71.png"'></image>
            </view>
            <input class='flex-sub' type="number" :placeholder="$t('请输入手机号码')" confirm-type="done" :maxlength="11"
              placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx" v-model="variableObj.phone" />
          </view>
          <view class='flex flex-wrap align-center loginPage_fd3_0_c1'>
            <image class='loginPage_fd3_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"74.png"'></image>
            <input class='flex-sub' type="number" :placeholder="$t('请输入验证码')" confirm-type="done" :maxlength="4"
              placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx" v-model="variableObj.code" />
            <benben-send-verification-code ref="vCode1699578889801" class=' loginPage_fd3_0_c1_c2' after-text='後重新獲取'
              :before-text="$t('获取验证码')" type='3' :phone="variableObj.phone"></benben-send-verification-code>
          </view>
        </view>
        <view class='flex flex-direction flex-wrap align-stretch' v-if=" tabls=='2'">
          <view class='flex flex-wrap align-center loginPage_fd3_0_c0'>
            <image class='loginPage_fd3_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"72.png"'></image>
            <input class='flex-sub' type="text" :placeholder="$t('请输入邮箱号')" confirm-type="done" :maxlength="-1"
              placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx" v-model="variableObj.email" />
          </view>
          <view class='flex flex-wrap align-center loginPage_fd3_1_c1'>
            <image class='loginPage_fd3_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"73.png"'></image>
            <benben-flex-password-diy v-model="variableObj.paswd"
              class-name="flex align-center flex loginPage_fd3_1_c1_c1" :placeholder="$t('请输入密码（6~12位数字+字母）')"
              :maxlength="12" :default-type='true' placeholder-style="color:#999;font-size:32rpx">
              <template #show>
                <text class='fu-iconfont2  loginPage_fd3_1_c1_c1_icon1' data-type="show">&#xE837;</text>
              </template>
              <template #hide>
                <text class='fu-iconfont2  loginPage_fd3_1_c1_c1_icon2' data-type="hide">&#xEBCC;</text>
              </template>
            </benben-flex-password-diy>
          </view>
          <view class='flex flex-wrap align-center justify-end loginPage_fd3_1_c2'>
            <text class='loginPage_fd3_1_c2_c0'>{{$t('忘记密码')}}</text>
          </view>
        </view>
        <view class='flex flex-direction flex-wrap align-center loginPage_fd3_2'>
          <button class='loginPage_fd3_2_c0' @tap.stop="validationLoginFunc()">{{$t('登录')}}</button>
          <text class='loginPage_fd3_2_c1' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/registerg/registerg`">{{$t('注册账号')}}</text>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-direction align-center benben-position-layout flex loginPage_flex_4">
        <view class='flex flex-wrap align-center loginPage_fd4_0'>
          <benben-flex-switch-new class-name='flex flex loginPage_fd4_0_c0' v-model="variableObj.is_agreent"
            :disabled='false'>
            <template v-slot:checked>

              <view class='flex flex position-relative align-center'>
                <image class='loginPage_checkfd4_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"20.png"'></image>
              </view>

            </template>
            <template v-slot:unchecked>

              <view class='flex flex position-relative justify-end align-center'>
                <image class='loginPage_checkfd4_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"21.png"'></image>
              </view>

            </template>
          </benben-flex-switch-new>
          <text class='loginPage_fd4_0_c1'>{{$t('我已阅读并同意')}}</text>
          <text class='loginPage_fd4_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/agreements/agreements`">{{$t('《用户注册协议》')}}</text>
          <text class='loginPage_fd4_0_c1'>{{$t('与')}}</text>
          <text class='loginPage_fd4_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/privacyPolicy/privacyPolicy`">{{$t('《隐私政策》')}}</text>
        </view>

      </view>
      <view :style="{height: '100rpx'}"></view>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "tabsInfofd2_0": {
          lineleft: '',
          lineWidth: '',
          moveX: 0,
          scrollX: 0,
          PageScrollX: 0
        },
        "tabls": "1",
        "state": "1",
        "variableObj": {
          "phone": "",
          "code": "",
          "email": "",
          "paswd": "",
          "is_agreent": false
        },
        "data": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": "",
            "client_id": "",
            "phone": ""
          }
        },
        "datatliat": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": "",
            "client_id": "",
            "phone": ""
          }
        }
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //切换语言
      switchLanguageFunc(lagun) {
        this.$store.commit('setLocale', {
          "locale": lagun
        })
      },
      //效验登录
      async validationLoginFunc() {
        if (this.tabls == '1') {
          if (!validate(this.variableObj.phone, 'require')) {
            this.$message.info('手机号不能为空');
            return false;
          }
          if (!validate(this.variableObj.phone, 'phone')) {
            this.$message.info('请输入正确的手机号');
            return false;
          }
          if (!validate(this.variableObj.code, 'require')) {
            this.$message.info('验证码不能为空');
            return false;
          }
          if (!validate(this.variableObj.code, 'captcha')) {
            this.$message.info('请输入正确的验证码');
            return false;
          }
        } else if (this.tabls == '2') {
          if (!validate(this.variableObj.email, 'require')) {
            this.$message.info('邮箱号不能为空');
            return false;
          }
          if (!validate(this.variableObj.email, 'email')) {
            this.$message.info('请输入正确的邮箱号');
            return false;
          }
          if (!validate(this.variableObj.paswd, 'require')) {
            this.$message.info('密码不能为空');
            return false;
          }
          if (!validate(this.variableObj.paswd, 'password')) {
            this.$message.info('请输入密码（6~12位数字+字母）');
            return false;
          }
        }
        if (this.variableObj.is_agreent === false) {
          this.$message.info('请勾选用户注册协议');
          return false;
        }
        //请求方法
        //数据验证

        let datadata = await this.$api.post(global.apiUrls.post5c78dca45ebc1, {
          mobile: this.variableObj.phone,
          code: this.variableObj.code,
          type: '3',
          email: this.variableObj.email
        });

        if (datadata.data.code != 1) {
          this.$message.info(datadata.data.msg);
          return
        }
        let infodata = datadata.data;
        this.data = infodata.data

        this.$store.commit('saveToken', this.data.userinfo.user_token)
        this.$store.commit('updateUserInfo', this.data.userinfo)
        this.toHomeDiy();
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(image-path('2.png')) no-repeat, #FFFFFF;
    background-size: 100% auto;
  }

  .loginPage_fd0_0_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_fd0_0_c0 {
    color: #333333;
    font-size: 26rpx;
    font-weight: 400;
    line-height: 26rpx;
    margin: 0rpx 8rpx 0rpx 0rpx;
  }

  .loginPage_fd0_0 {
    background: rgba(255, 255, 255, 1);
    margin: 100rpx 32rpx 0rpx 0rpx;
    width: 192rpx;
    height: 64rpx;
    border-radius: 32rpx;
    background-size: 100% auto;
  }

  .loginPage_flex_1 {
    margin: 67rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_fd1_0 {
    width: 412rpx;
    height: 120rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 32rpx;
  }

  .loginPage_flex_2 {
    margin: 88rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_titlefd2_0_c4 {
    margin: 0rpx 48rpx 0rpx 0rpx;
  }

  .loginPage_titlefd2_0_c3 {
    margin: 0rpx 48rpx 0rpx 32rpx;
  }

  .loginPage_linefd2_0 {
    background: rgba(1, 129, 255, 1);
    width: 42rpx;
    height: 8rpx;
    top: 80rpx;
    background-size: 100% auto !important;
    border-radius: 4rpx;
  }

  .checkTitlefd2_0 {
    font-weight: 500 !important;
    font-size: 32rpx !important;
    color: rgba(51, 51, 51, 1) !important;
  }

  ::v-deep .loginPage_benbenTabsfd2_0 {
    width: 750rpx;
    height: 90rpx;
    white-space: nowrap;
    text-align: center;
    font-size: 32rpx;
    font-weight: 400;
    color: #999999;
  }

  .loginPage_flex_3 {
    margin: 40rpx 0rpx 0rpx 0rpx;
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .loginPage_fd3_2_c1 {
    color: #0181FF;
    font-size: 32rpx;
    font-weight: 400;
    line-height: 44rpx;
    margin: 40rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_fd3_2_c0 {
    background: #0181FF;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 686rpx;
    line-height: 96rpx;
    font-size: 32rpx;
    color: #fff;
    height: 96rpx;
    box-shadow: 0rpx 10rpx 20rpx 1rpx rgba(1, 129, 255, 0.2);
  }

  .loginPage_fd3_2 {
    margin: 64rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_fd3_1_c2_c0 {
    color: #999999;
    font-size: 32rpx;
    font-weight: 400;
    line-height: 44rpx;
  }

  .loginPage_fd3_1_c2 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_fd3_1_c1_c1_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .loginPage_fd3_1_c1_c1_icon1 {
    text-align: center;
    font-size: 40rpx;
  }

  ::v-deep .loginPage_fd3_1_c1_c1 {
    font-size: 32rpx;
    width: 566rpx;
    height: 50rpx;
  }

  .loginPage_fd3_1_c1 {
    background: rgba(255, 255, 255, 1);
    border-radius: 24rpx;
    background-size: 100% auto;
    padding: 24rpx;
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .loginPage_fd3_0_c1_c2 {
    line-height: 44rpx;
    text-align: center;
    font-size: 32rpx;
    color: #0181FF;
    font-weight: 400;
  }

  .loginPage_fd3_0_c1 {
    background: rgba(255, 255, 255, 1);
    margin: 32rpx 0rpx 0rpx 0rpx;
    border-radius: 24rpx;
    background-size: 100% auto;
    padding: 24rpx;
  }

  .loginPage_fd3_0_c0_c1_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 8rpx;
  }

  .loginPage_fd3_0_c0_c1_c0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 400;
    line-height: 44rpx;
  }

  .loginPage_fd3_0_c0_c1 {
    border-right: 1px solid #eee;
    padding: 0rpx 16rpx 0rpx 0rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .loginPage_fd3_0_c0_c0 {
    width: 40rpx;
    height: 40rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .loginPage_fd3_0_c0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 24rpx;
    background-size: 100% auto;
    padding: 24rpx;
  }

  .loginPage_flex_4 {
    width: 750rpx;
    height: 100rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(48rpx + var(--window-bottom));
  }

  .loginPage_fd4_0_c2 {
    line-height: 41rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: #0181FF;
  }

  .loginPage_fd4_0_c1 {
    line-height: 41rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
  }

  .loginPage_checkfd4_0_c0_c0_c0 {
    width: 32rpx;
    height: 32rpx;
  }

  ::v-deep .loginPage_fd4_0_c0 {
    margin: 0rpx 8rpx 0rpx 0rpx;
  }

  .loginPage_fd4_0 {
    margin: auto 0rpx 32rpx 0rpx;
  }
</style>